package com.maximus.tools.config;

import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.lookup.StrLookup;

@Plugin(name = "baseurl", category = "Lookup")
public class BaseUrlLookUp implements StrLookup {
    @Override
    public String lookup(String key) {
        key = key.toLowerCase();
        if (key.contains("win") || key.contains("linux")) {
            return "/logs/JavaRedis";
        } else if (key.contains("mac")) {
            String user = System.getProperty("user.name");
            return "/Users/" + user + "/Documents/logs/JavaRedis";
        }
        return "/logs/JavaRedis";
    }

    @Override
    public String lookup(LogEvent event, String key) {
        return lookup(key);
    }
}
